<?php
namespace app\common\model;

use think\Model;
use think\Db;

class Client extends Model
{
    protected $insert = ['create_time'];

    protected static function init(){
        self::beforeInsert(function ($model) {
            $where = [
                'id'=>['eq',$model['count_id']],
                'yid'=>['neq',0]
            ];
            if(Db::name('adcount')->where($where)->value('id') == null){
                return false;
            }else{
                return;
            }
        });
    }

    protected function setCreateTimeAttr()
    {
        return time();
    }

    protected function getCreateTimeAttr($value){
        return date('Y-m-d H:i:s',$value);
    }
}